home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mintmant / psignal.txt < prev    next >
Text File  |  1992-03-24  |  4KB  |  129 lines

  1. Psignal(2)                Oct. 1, 1991                 Psignal(2)
  2.  
  3.  
  4.  
  5. NAME
  6.      Psignal - change the way a signal is handled
  7.  
  8. SYNOPSIS
  9.      #include <signal.h>
  10.  
  11.      LONG Psignal(WORD sig, LONG handler);
  12.  
  13. DESCRIPTION
  14.      Psignal changes the handling of the signal indicated by  sig
  15.      (which must be between 1 and 31; symbolic constants for sym-
  16.      bols are defined in  the  file  signal.h).  The  new  signal
  17.      handler applies to this process only.
  18.  
  19.      If handler is SIG_DFL, then the default action for the  sig-
  20.      nal will occur when the signal is delivered to the process.
  21.  
  22.      If handler is SIG_IGN, then the signal will  be  ignored  by
  23.      the process, and delivery of the signal will have no notice-
  24.      able effect (in particular, the signal  will  not  interrupt
  25.      the  Pause  system  call, q.v.). If the signal is pending at
  26.      the time of the Psignal call, it is discarded.
  27.  
  28.      If handler is some other value, it  is  assumed  to  be  the
  29.      address of a user function that will be called when the sig-
  30.      nal is delivered to the process. The user function is called
  31.      with  a  single  LONG  argument  on  the stack, which is the
  32.      number of the signal being delivered (this is done  so  that
  33.      processes may use the same handler for a number of different
  34.      signals). While the signal is being handled, it  is  blocked
  35.      from  delivery;  thus, signal handling is "reliable" (unlike
  36.      Version 7 and early System V Unix implementations, in  which
  37.      delivery of a second signal while it was being handled could
  38.      kill the process). Also note that, unlike some  versions  of
  39.      Unix,  the  signal  handling  is  *not* reset to the default
  40.      action before the handler is called; it remains set  to  the
  41.      given signal handler.
  42.  
  43.      The signal handler must either return (via  a  normal  680x0
  44.      rts instruction) or call the Psigreturn system call to indi-
  45.      cate when signal handling is complete; in  both  cases,  the
  46.      signal  will  be  unblocked.  Psigreturn  also performs some
  47.      internal clean-up of the kernel stack that is  necessary  if
  48.      the  signal  handler is not planning to return (for example,
  49.      if the C longjmp() function is to be used to continue execu-
  50.      tion at another point in the program).
  51.  
  52.      Signal handlers may make any GEMDOS, BIOS, or  XBIOS  system
  53.      calls freely.  GEM AES and VDI calls should not be made in a
  54.      signal handler.
  55.  
  56.  
  57.  
  58.  
  59.  
  60. Version 0.9   Last change: MiNT Programmer's Manual             1
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67. Psignal(2)                Oct. 1, 1991                 Psignal(2)
  68.  
  69.  
  70.  
  71.      Note that calling Psignal to change behavior of a signal has
  72.      the  side  effect of unmasking that signal, so that delivery
  73.      is possible. This is done so that processes may, while  han-
  74.      dling  a  signal,  reset  the  behavior  and send themselves
  75.      another instance of the signal,  for  example  in  order  to
  76.      suspend  themselves  while  handling a job control signal.
  77.      Signal handling is preserved across Pfork and Pvfork  calls.
  78.      Signals  that  are ignored by the parent are also ignored by
  79.      the child after a Pexec call; signals that were being caught
  80.      for  handling  in  a  function are reset in the child to the
  81.      default behavior.
  82.  
  83. RETURNS
  84.      The old value of the signal handler on success; this will be
  85.      either SIG_DFL, SIG_IGN, or a function address.
  86.  
  87.      ERANGE if sig is not a legal signal.
  88.  
  89.      EACCDN if the signal may not be caught by the user
  90.  
  91. SEE ALSO
  92.      Pkill(2), Psigblock(2), Psigreturn(2)
  93.  
  94. BUGS
  95.      Signal handling can be nested only a small (around 3) number
  96.      of  times, i.e. if 4 signals are delivered to a process, and
  97.      the process has established handlers for all 4, and none  of
  98.      the handlers has returned or called Psigreturn,  then  there
  99.      is  a  very  good  chance of a stack  overflow  killing  the
  100.      process off. In practice, this is unlikely to happen.
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125. Version 0.9   Last change: MiNT Programmer's Manual             2
  126.  
  127.  
  128.  
  129.